from selenium import webdriver
from selenium.webdriver import ActionChains, Keys
import time
options = webdriver.ChromeOptions()

options.page_load_strategy = "normal"  # 等待页面完全加载
# 创建浏览器驱动对象
driver = webdriver.Chrome(options=options)
action = ActionChains(driver)
url = r"https://y.qq.com/"
driver.get(url)
cookie = "RK=U9UMgLxOc8; ptcz=38c12b0754fa9b440cf198190f2bc70902df8447fd6f247fe3687de16135fdd8; pgv_pvid=263163392; fqm_pvqid=34b5b884-d339-4f1a-ae4b-5dfa7bcf4ef1; fqm_sessionid=051f5201-3f3b-4651-a2d4-ae08d93af8ad; pgv_info=ssid=s9570692237; ts_last=y.qq.com/; ts_uid=4246579422; _qpsvr_localtk=0.6041328539675492; login_type=1; psrf_qqrefresh_token=C89EB042AD04C45BD1FCF4CB7DDAECE9; euin=oK457e4ioKCFon**; qqmusic_key=Q_H_L_63k3NokqgsEIxwtUefZK1RSsKGpyJzAD9UqLxAIXRI7fGjBs-pQ3JxQrxLHPKP-RtwDF-Q-BqU17CbiBPC0bAiw; tmeLoginType=2; qm_keyst=Q_H_L_63k3NokqgsEIxwtUefZK1RSsKGpyJzAD9UqLxAIXRI7fGjBs-pQ3JxQrxLHPKP-RtwDF-Q-BqU17CbiBPC0bAiw; music_ignore_pskey=202306271436Hn@vBj; wxunionid=; uin=1514531680; psrf_qqopenid=24F5B17390258EBDA296C7FCC487EF1E; psrf_musickey_createtime=1742872761; psrf_qqunionid=D8857A1BC18044A93A5303F63CA3C99A; psrf_qqaccess_token=266CF771250591A9C888533DA495D77F; wxrefresh_token=; wxopenid=; psrf_access_token_expiresAt=1748056761"
for c in cookie.split("; "):
    name = c.split("=")[0]
    value = c.split("=")[1]
    print(name, value)
    driver.add_cookie({"name": name, "value": value})
time.sleep(3)
driver.refresh()
driver.get_screenshot_as_file("./jt.png")
input("按任意键关闭")
# # 关闭驱动对象
driver.close()
driver.quit()
print("结束")
